<template>
  <div>
    <van-overlay :show="isShow"/>
    <div class="dlg" v-show="isShow">
      <div class="header">VIP会员购买记录</div>
      <div class="table-header">
        <table>
          <thead>
            <tr>
              <th>购买时间</th>
              <th>购买种类</th>
              <th>有效天数</th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="content">
        <table>
          <tbody>
            <tr v-for="(item, index) in vipRecord" :key="index">
              <td>
                <div>{{item.addtime | formatTimestamp}}</div>
                <div>{{item.addtime | Timestamp}}</div>
              </td>
              <td>{{item.remarks}}</td>
              <td>{{item.expiry_time}}</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="btn" @click="closeClick">我知道了</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isShow: {
      type: Boolean,
      default() {
        return {}
      }
    },
    vipRecord: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {}
  },
  methods: {
    closeClick() {
      this.$emit('close-click',false)
    }
  },
  filters: {
    getFixed(e) {
      return e.toFixed(2)
    },
    formatTimestamp( timestamp ) {
      var dateObj = new Date( timestamp * 1000 );   
      var year = dateObj.getYear() + 1900;
      var month = dateObj.getMonth() + 1;
      month = month < 10 ? '0' + month : month
      var theDate = dateObj.getDate();
      theDate = theDate < 10 ? '0' + theDate : theDate
      var hour = dateObj.getHours();
      var minute = dateObj.getMinutes();
      var second = dateObj.getSeconds();
  //     return year +"-"+ month +"-" + theDate + " "+ hour +":"+ minute +":"+ second;     
      return year +"-"+ month +"-" + theDate     
    },
    Timestamp( timestamp ) {
      var dateObj = new Date( timestamp * 1000 );   
      var year = dateObj.getYear() + 1900;
      var month = dateObj.getMonth() + 1;
      var theDate = dateObj.getDate();
      var hour = dateObj.getHours();
      var minute = dateObj.getMinutes();
      minute = minute < 10? '0' + minute : minute;
      var second = dateObj.getSeconds();
      second = second < 10? '0' + second : second;
      return hour +":"+ minute +":"+ second
    }
  }
}
</script>

<style scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
}

.dlg {
  position: relative;
  box-sizing: border-box;
  padding: .533333rem .133333rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 8.533333rem;
  height: auto;
  background: #FFFFFF;
  border-radius: .4rem;
  z-index: 2;
}

.header {
  font-size: .48rem;
  font-weight: bold;
  line-height: .6rem;
  color: #222222;
  text-align: center;
}


.content {
  width: 100%;
  height: 4.48rem;
  margin: 0 0 .533333rem 0;
  overflow: scroll;
}

.content::-webkit-scrollbar {
  display: none;
}

table {
  border-collapse:collapse;
}

tr {
  height: 1.12rem;
  border-bottom: .013333rem solid #DDDDDD;
}

th,td {
  width: 2.746667rem;
  text-align: center;
}

th {
  font-size: .346667rem;
  font-weight: 400;
  color: #222222;
}

tbody {
  font-size: .32rem;
  font-weight: 400;
  color: #666666;
}

.btn {
  margin: 0 auto;
  width: 4.8rem;
  height: .906667rem;
  background: linear-gradient(133deg, #FFD892 0%, #EBA448 100%);
  border-radius: .76rem;
  text-align: center;
  line-height: .906667rem;
  font-size: .346667rem;
  font-weight: bold;
  color: #FFFFFF;
}

.van-overlay {
  z-index: 1;
}
</style>